import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/views/home'
import Index from '@/views/index'
import Product from '@/views/product'
import Detail from '@/views/detail'
import Cart from '@/views/cart'
import order from '@/views/order/order'
import orderList from '@/views/order/orderList'
import orderConfirm from '@/views/order/orderConfirm'
import orderPay from '@/views/order/orderPay'
import aliPay from '@/views/order/aliPay'

Vue.use(Router)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    redirect: '/index',
    children: [
      {
        path: '/index',
        name: 'index',
        component: Index
      },
      {
        path: '/product/:id',
        name: 'product',
        component: Product
      },
      {
        path: '/detail/:id',
        name: 'detail',
        component: Detail
      }
    ]
  },
  {
    path: '/cart',
    name: 'cart',
    component: Cart
  },
  {
    path: '/order',
    name: 'order',
    component: order,
    children: [
      {
        path: 'list',
        name: 'orderList',
        component: orderList
      },
      {
        path: 'confirm',
        name: 'orderConfirm',
        component: orderConfirm
      },
      {
        path: 'pay',
        name: 'orderPpay',
        component: orderPay
      },
      {
        path: 'alipay',
        name: 'aliPpay',
        component: aliPay
      }
    ]
  }
]

const router = new Router({
  routes
})

export default router
